<template>
  <div id="app-container" style="padding:30px;">
    <el-form label-width="130px">
      <el-form-item label="选择批次">
        <el-col :span="5">
          <el-input v-model="bookList.batchId"/>
        </el-col>
      </el-form-item>
      <el-form-item label="书单名称">
        <el-col :span="5">
          <el-input v-model="bookList.name"/>
        </el-col>
      </el-form-item>
      <el-form-item>
        <el-button :disabled="saveBtnDisabled" type="primary" @click="save()">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  import bookList from "@/api/copyrightin/bookList/bookList";
  export default {
    data() {
      return {
        bookList: {
          id: 1
        },
        saveBtnDisabled: false,
      }
    },
    created() {
      this.init()
    },
    methods: {
      init() {
        if (this.$route.params && this.$route.params.id) {
          const id = this.$route.params.id
          this.view(id)
        }
      },
      view(id) { // 根据id进行数据查询,回显数据
        bookList.view(id)
          .then(response => {
            this.bookList = response.data.bookList
          })
      },
      save() { //修改
        bookList.updateBookList(this.bookList)
          .then(response => {
            this.$message({
              type: 'success',
              message: '修改成功'
            })
            this.$router.push('/bms/copyright/bookList/list')
          })
      }
    }
  }
</script>
